<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="org.springframework.web.context.WebApplicationContext"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="db.AuthorityDAO"%>
<%@page import="db.UserDAO"%>
<%@page import="db.User"%>
<%@page import="db.TitleDAO"%>
<%@page import="db.Title"%>
<%@page import="db.Authority"%>
<%@page import="db.TeamDAO"%>
<%@page import="db.MsgDAO"%>
<%
	WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
	AuthorityDAO authorityDao = (AuthorityDAO)ctx.getBean("AuthorityDAO");
	UserDAO userDao = (UserDAO)ctx.getBean("UserDAO");
	TitleDAO titleDao = (TitleDAO)ctx.getBean("TitleDAO");
	TeamDAO teamDao = (TeamDAO)ctx.getBean("TeamDAO");
	
	Integer userId = (Integer)session.getAttribute("id");
	if(userId != null){
		User user = userDao.findById(userId);
		request.setAttribute("user",user);
		
		Title title = titleDao.findById(user.getTitleId());
		request.setAttribute("title",title);
		
		List list = authorityDao.findByUserId(userId);
		Map map = new HashMap();
		for(int i=0;i<list.size();i++){
			Authority authority = (Authority)list.get(i);
			String model = authority.getModule1() + "-" + authority.getModule2();
			map.put(authority.getModule1() + "",authority.getModule1());
			map.put(authority.getModule1() + "-" + authority.getModule2(),1);
		}
		request.setAttribute("authMap",map);
		
		List teamList = teamDao.findAll();
		request.setAttribute("teamList",teamList);
		
		pageContext.forward("/vm/erp_tpl/left.vm");
	}else{
		pageContext.forward("/index.jsp");
		return;
	}
%>